<?php
require_once substr(dirname(__FILE__),0,-1).'sub/init.php';
if(!in_array('qun',$navarr))exit('该功能已关闭');
require_once ZEAI.'sub/conn.php';
require_once ZEAI.'m/div_left_so.php';
$nodatatips = "<div class='nodatatips' style='margin:0 auto'><br><i class='ico'>&#xe608;</i>暂时木有内容</div>";
$t = ($t!=2 || empty($t))?1:2;$jumpurl = mHref('qun');
/***********************主体入口***************************/
$_ZEAI['pagesize']= 8;
$ZEAI_SQL = "flag=1 ";
//处理表单
$keyword = trimhtml(dataIO($keyword,'out'));
$tag = trimhtml(dataIO($tag,'out'));
$ifmy=intval($ifmy);
$addtime=intval($addtime);
if (!empty($keyword)){
	if (ifint($keyword)){
		$ZEAI_SQL .= " AND id='$keyword' ";
	}else{
		$ZEAI_SQL .= " AND (title LIKE '%".$keyword."%' OR tag LIKE '%".$keyword."%') ";
	}
}
$nav = 'qun';
if($t==2){
	if(!iflogin())header("Location: ".mHref('login').'?jumpurl='.$jumpurl);
	$rt=$db->query("SELECT qid FROM ".__TBL_QUN_U__." WHERE uid=".$cook_uid." ORDER BY id DESC");
	$total = $db->num_rows($rt);
	if ($total > 0) {
		$myqidlist=array();
		for($i=1;$i<=$total;$i++) {
			$rows = $db->fetch_array($rt,'num');
			if(!$rows) break;
			$myqidlist[] = $rows[0];
		}
		$myqidlist = (is_array($myqidlist))?implode(',',$myqidlist):'';
	}
	if(!empty($myqidlist)){$ZEAI_SQL .= " AND id in ($myqidlist) ";}else{$ZEAI_SQL .= " AND 1=2";};
	$nav = 'my';
}
if(ifint($addtime)){$addtimeF=$addtime*86400;$ZEAI_SQL .= " AND (".ADDTIME." - addtime) < $addtimeF";}
$areaid=trimhtml(dataIO($areaid,'out'));$areaid=getareaSQL($areaid);if(!empty($areaid))$ZEAI_SQL .= " AND areaid LIKE '%".$areaid."%' ";
$areatitle=trimhtml(dataIO($areatitle,'out'));
//参数
$cs  ="t=".$t."&keyword=".$keyword."&areaid=".$areaid."&addtime=".$addtime;
//主语句
$ZEAI_SELECT = "SELECT id,title,path_s,tag,price FROM ".__TBL_QUN__." WHERE ".$ZEAI_SQL." ORDER BY px DESC,id DESC";
//统计
$rtt  = $db->query("SELECT COUNT(*) FROM ".__TBL_QUN__." WHERE ".$ZEAI_SQL);$roww = $db->fetch_array($rtt);
$ZEAI_total=$roww[0];
$ZEAI_totalP = ceil($ZEAI_total/$_ZEAI['pagesize']);
if ($submitok == 'ajax_list'){exit(Zeai_ajax_list_fn($ZEAI_totalP,$p));}	
/*********************** BODY 开始***************************/
?>
<!doctype html><html><head><meta charset="utf-8">
<title>单身群•相亲群 - <?php echo $_ZEAI['siteName'];?></title>
<?php echo HEADMETA; ?>
<meta name="generator" content="Zeai.cn V9.0" />
<link href="<?php echo RES;?>m/css/m.css?<?php echo $_ZEAI['cache_str'];?>" rel="stylesheet" type="text/css" />
<link href="<?php echo HOST;?>/cache/zeaicolor.css?<?php echo $_ZEAI['cache_str'];?>" rel="stylesheet" type="text/css" />
<link href="<?php echo RES;?>m/css/qun.css?<?php echo $_ZEAI['cache_str'];?>" rel="stylesheet" type="text/css" />
<script src="<?php echo RES;?>www_zeai_cn.js?<?php echo $_ZEAI['cache_str'];?>"></script>
<script src="<?php echo RES;?>m/js/m.js?<?php echo $_ZEAI['cache_str'];?>"></script>
<script src="<?php echo HOST;?>/cache/areadata.js?<?php echo $_ZEAI['cache_str'];?>"></script>
<script src="<?php echo RES;?>m/js/zeai_div_area.js?<?php echo $_ZEAI['cache_str'];?>"></script>
<script src="<?php echo RES;?>m/js/qun.js?<?php echo $_ZEAI['cache_str'];?>"></script>
<script src="<?php echo RES;?>zeai_ios_select/separate/select.js?<?php echo $_ZEAI['cache_str'];?>"></script>
<?php
if (is_weixin()){
	require_once ZEAI."api/weixin/jssdk.php";?>
	<script src="<?php echo RES;?>jweixin-1.2.0.js"></script>
	<script>
	wx.config({debug:false,
		appId: '<?php echo $signPackage["appId"];?>',
		timestamp: <?php echo $signPackage["timestamp"];?>,
		nonceStr: '<?php echo $signPackage["nonceStr"];?>',
		signature: '<?php echo $signPackage["signature"];?>',
		jsApiList: ['hideMenuItems','onMenuShareTimeline','onMenuShareAppMessage','onMenuShareQQ','onMenuShareWeibo']
	});
	var share_title = '单身群•相亲群 - <?php echo dataIO($_ZEAI['siteName'],'out'); ?>',
	share_desc  = '全城优质单身男女在群里，只与同类人约见！',
	share_link  = '<?php echo mHref('qun'); ?>',
	share_imgUrl= '<?php echo UP.$_ZEAI['logo']; ?>';
	wx.ready(function () {
		wx.onMenuShareAppMessage({title:share_title,desc:share_desc,link:share_link,imgUrl:share_imgUrl});
		wx.onMenuShareTimeline({title:share_title,link:share_link,imgUrl:share_imgUrl});
	});
	</script>
<?php }?>
<style>
.ulist_search{box-shadow:0 .3rem .8rem rgba(<?php echo c16_rgb($_ZEAI['mob_mbcolor']);?>,.4)}
.qun_list a button{color:<?php echo $_ZEAI['mob_mbcolor'];?>;border:<?php echo $_ZEAI['mob_mbcolor'];?> 1px solid;position:absolute;right:1.5rem}
/*div_left_so*/
.div_left_so a.ed,
.div_left_so a.ed:after{color:<?php echo $_ZEAI['mob_mbcolor'];?>}
.div_left_so ul.def li.ed{color:<?php echo $_ZEAI['mob_mbcolor'];?>;background-color:rgba(<?php echo c16_rgb($_ZEAI['mob_mbcolor']);?>,.1)}
.div_left_so .listbox dl dd span.ed{color:<?php echo $_ZEAI['mob_mbcolor'];?>;border-top-color:<?php echo $_ZEAI['mob_mbcolor'];?>}
.div_left_so_areabox .ul dt.ed{color:<?php echo $_ZEAI['mob_mbcolor'];?>;border-top-color:<?php echo $_ZEAI['mob_mbcolor'];?>}
.div_left_so_areabox .ul li a.ed{color:<?php echo $_ZEAI['mob_mbcolor'];?>;background-color:rgba(<?php echo c16_rgb($_ZEAI['mob_mbcolor']);?>,.1)}
.qun_list a dd ul li{background-color:rgba(<?php echo c16_rgb($_ZEAI['mob_mbcolor']);?>,.05);color:<?php echo $_ZEAI['mob_mbcolor'];?>;border:rgba(<?php echo c16_rgb($_ZEAI['mob_mbcolor']);?>,.1) 1px solid}
.areabox .ul li a.ed{color:<?php echo $_ZEAI['mob_mbcolor'];?>;background-color:rgba(<?php echo c16_rgb($_ZEAI['mob_mbcolor']);?>,.1)}
.areabox .ul dt.ed{color:<?php echo $_ZEAI['mob_mbcolor'];?>;border-top-color:<?php echo $_ZEAI['mob_mbcolor'];?>}
/*topnav*/
.topnav1{background-image:url("<?php echo RES;?>m/img/my_bg.png");background-color:<?php echo $_ZEAI['mob_mbcolor'];?>}
.topnav a.ed:after{background-color:<?php echo $_ZEAI['mob_mbcolor'];?>}
.topnav1 a.ed:after{background-color:#fff}
</style>
</head><body>
<?php if ($_ZEAI['m_mb']==2){$nav='qun';$TRnav_btn = 'hide';$mainstyle=' style="margin-top:1.2rem"';require_once ZEAI.'m/top2.php';?>
	<div class="tab2">
        <a href="qun.php?t=1"><i class="_new ico">&#xe647;</i><span>最新</span></a>
        <a href="qun.php?t=2"><i class="_my ico">&#xe63e;</i><span>我的</span></a>
        <a id="qun_search"><i class="_so ico">&#xe68c;</i><span>筛选</span></a>
    </div>
<?php }else{ ?>
    <div class="topnav topnav1">
        <a href="qun.php"<?php echo ($t == 1)?' class="ed"':'';?>>单身群</a>
        <a href="qun.php?t=2"<?php echo ($t == 2)?' class="ed"':'';?>>我加的</a>
    </div>
    <a class="ulist_search zeaibg" id="qun_search"><i class="ico">&#xe66c;</i> 筛选</a>
<?php }?>
<div class="qun_list" id="ZEAI_list"<?php echo $mainstyle;?>><?php if($ZEAI_totalP>0){echo Zeai_ajax_list_fn($ZEAI_totalP,$p);}else{echo $nodatatips;}?></div>
<?php if ($ZEAI_total > $_ZEAI['pagesize']){?>
<script>
var ZEAI_totalP = parseInt(<?php echo $ZEAI_totalP; ?>),p=2;
var scs='<?php echo trimhtml($cs); ?>';
var postjson = {submitok:'ajax_list',ZEAI_totalP:ZEAI_totalP};
if(!zeai.empty(scs))Object.assign(postjson,tojson(scs.split('&')));
zeaiOnscroll_json={url:MHOST+'/qun'+zeai.extname,data:postjson};
document.body.onscroll = function(){zeaiOnscroll();};
</script>
<div id="backtop"><a href="#top" id="btmTopBtn"><i class="ico zeaicolor">&#xe60c;</i><span class="zeaicolor">顶部</span></a></div>
<?php }?>
<!--div_left_so-->
<div class="div_left_so" id="qun_so">
	<form action="qun.php" class="form_uid" name="www.zeai.cn">
        <input name="keyword" type="text" class="input" id="keyword" maxlength="20" value="<?php echo $keyword;?>" placeholder="按群ID/群名称/群标签" autocomplete="off">
        <button type="submit" class="ico">&#xe6c4;</button>
	</form>
    <form action="qun.php" method="get" name="www.yzlove.com">
    <?php
	div_left_so_out(array('tbody'=>'创建时间','t'=>'addtime','tv'=>$addtime,'subkind'=>2,'newarr'=>json_decode('[{"i":"3","v":"3天内"},{"i":"7","v":"1周内"},{"i":"30","v":"1月内"},{"i":"180","v":"6月内"},{"i":"365","v":"1年内"}]'),'ulcls'=>' col3'));
	?>
    <!--gz-->
    <div id="areabox" class="areabox"><div class="ul"><li><dl><dd></dd></dl></li></div></div>
    <input type="hidden" id="form_areaid" name="areaid" value="<?php echo $areaid;?>">
    <input type="hidden" id="form_areatitle" name="areatitle" value="<?php echo $areatitle;?>">
    <div class="listbox">
        <dl id="areaid" data="<?php echo $areaid;?>"><dt>群地区</dt><dd><span id="areatitle"><?php echo $areatitle;?></span></dd></dl>
    </div>
    
    <div class="savebox"><button type="button" class="btn size3 reset" id="div_left_so_resetbtn" onClick="div_left_so_reset('qun_so')">重置</button><button type="submit" class="btn size3 zeaibg ico">&#xe6c4; 确定</button></div>
    </form>
</div>
<script>qun_search.onclick=qun_search_btnFn;o('areaid').onclick=areaidFn</script>
<!--div_left_so end-->
<?php
if ($ZEAI_total <= $_ZEAI['pagesize']){echo '<div class="blank"></div>';}
require_once ZEAI.'m/TRnav.php';
if($_ZEAI['m_mb']==2){
	echo "<script>setTimeout(function(){hdnavLRmoveFn(hdnav,90,'r');},100);</script>";
	require_once ZEAI.'m/bottom2.php';
}else{
	require_once ZEAI.'m/bottom.php';
}
if (is_weixin() && ifint($cook_uid)){wx_endurl('您刚刚浏览的页面【单身群】',mHref('qun'));}
function rows_ulist($rows) {
	global $_ZEAI,$db,$cook_uid;
	$fid    = $rows['id'];
	$path_s = $rows['path_s'];
	$title = dataIO($rows['title'],'out');
	$price = $rows['price'];
	$tag   = dataIO($rows['tag'],'out');
	$path_s_url = (!empty($path_s))?UP.$path_s:RES.'noP.gif';
	//
	$priceARR = json_decode($price,true);
	rsort($priceARR);$maxprice=max($priceARR);
	sort($priceARR);$minprice=min($priceARR);
	if($maxprice==0 && $minprice==0){
		$price_str=' <font class="C090">免费</font>';
	}else{
		$price_str='￥'.$minprice.'-'.$maxprice;
	}
	//
	$ifin = 0;
	if(ifint($cook_uid)){
		$rtt = $db->query("SELECT COUNT(*) FROM ".__TBL_QUN_U__." WHERE uid='$cook_uid' AND qid=$fid");
		$roww = $db->fetch_array($rtt);
		$ifin=$roww[0];
	}
	$addstr = ($ifin>0)?'已加入':'<i class="ico">&#xe622;</i>加群';
	$tagstr = '';
	if(!empty($tag)){
		$tagARR=explode('<br>',$tag);
		if (count($tagARR) >= 1 && is_array($tagARR)){
			$tagstr='<ul>';
			foreach ($tagARR as $V){$tagstr.='<li class="zeaicolor">'.$V.'</li>';}
			$tagstr.='</ul>';
		}
	}
	$echo = '<a href=\''.mHref('qun',$fid).'\' clsid="'.$fid.'">';
	$echo .= '<dt><img src="'.$path_s_url.'"></dt>';
	$echo .= '<dd><h4>'.$title.'</h4>';
	$echo .= $tagstr;
	$echo .= getqunUlist($fid);
	$echo .= '</dd>';
	$echo .= '<button class="size2 btn yuan">'.$addstr.'</button>';//HONG zeaibg 
	//$echo .= '<h6>入群费<b>'.$price_str.'</b>　共<b>'.$Unum.'</b>位成员</h6>';
	$echo .= '<div class="clear"></div></a>';
	return $echo;
}
function getqunUlist($fid) {
	global $db,$_ZEAI,$cook_grade;
	$rt=$db->query("SELECT U.sex,U.photo_s,U.photo_f,U.photo_ifshow,U.flag FROM ".__TBL_QUN_U__." a,".__TBL_USER__." U WHERE a.uid=U.id AND a.qid=$fid ORDER BY a.id DESC LIMIT 7");
	$echo = '';
	WHILE ($rows = $db->fetch_array($rt,'num')){
		$sex      = $rows[0];
		$photo_s  = $rows[1];
		$photo_f  = $rows[2];
		$photo_ifshow = $rows[3];
		$uflag    = $rows[4];
		$echo.=photo_s_out('{"sex":"'.$sex.'","photo_s":"'.$photo_s.'","photo_f":"'.$photo_f.'","photo_ifshow":"'.$photo_ifshow.'","uflag":"'.$uflag.'","outkind":"img"}');
	}
	return (!empty($echo))?'<em>'.$echo.'</em>':'';
}
?>